package tr.edu.metu.is.mega.common.dto;

/**
 * Enumeration for user roles.
 */
public enum ActivityType {

    ACTIVITY("A", "Activity"),

    REVIEW("R", "Review"),

    SUBMISSION("S", "Submission");

    private String code;

    private String description;

    /**
     * Default constructor.
     * 
     * @param code code
     * @param description description
     */
    private ActivityType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * Returns the code.
     * 
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * Returns the description.
     * 
     * @return description
     */
    public String getDescription() {
        return description;
    }

    /**
     * Finds a user role by its code.
     * 
     * @param code code
     * @return user role
     */
    public static ActivityType findByCode(String code) {
        for (ActivityType type : ActivityType.values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }

}
